Skip to content

Commit

Permalink
fix: revert 4.10.1 (#1992)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnagro authored Jan 18, 2024
1 parent 7afe90a commit 1e69e78
Show file tree
Hide file tree
Showing 16 changed files with 8 additions and 244 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Change Log
Unreleased
----------

[4.10.4]
--------

revert: 4.10.1

[4.10.3]
--------

Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "4.10.3"
__version__ = "4.10.4"

This file was deleted.

23 changes: 0 additions & 23 deletions integrated_channels/canvas/migrations/0033_auto_20240110_1301.py

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion integrated_channels/integrated_channel/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@

ISO_8601_DATE_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'
TASK_LOCK_EXPIRY_SECONDS = 60 * 60 * 12
TRANSMISSION_STATUS_RECORDS_LIMIT = 3

This file was deleted.

18 changes: 0 additions & 18 deletions integrated_channels/integrated_channel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
from django.db import models
from django.db.models import Q
from django.db.models.query import QuerySet
from django.utils import timezone
from django.utils.translation import gettext_lazy as _

from model_utils.models import TimeStampedModel

from enterprise.constants import TRANSMISSION_MARK_CREATE, TRANSMISSION_MARK_DELETE, TRANSMISSION_MARK_UPDATE
from enterprise.models import EnterpriseCustomer, EnterpriseCustomerCatalog
from enterprise.utils import localized_utcnow
from integrated_channels.integrated_channel.constants import TRANSMISSION_STATUS_RECORDS_LIMIT
from integrated_channels.integrated_channel.exporters.content_metadata import ContentMetadataExporter
from integrated_channels.integrated_channel.exporters.learner_data import LearnerExporter
from integrated_channels.integrated_channel.transmitters.content_metadata import ContentMetadataTransmitter
Expand Down Expand Up @@ -533,8 +531,6 @@ class LearnerDataTransmissionAudit(TimeStampedModel):
help_text=_('Data pertaining to the transmissions API request response.')
)

transmission_status = models.JSONField(default=list, blank=True, null=True)

class Meta:
abstract = True
app_label = 'integrated_channel'
Expand Down Expand Up @@ -607,20 +603,6 @@ def _payload_data(self):
'grade': self.grade,
}

def add_transmission_status(self, status_code, error_message):
"""
Append the new entry to the list, keeping the list limited to latest three entries.
"""
new_entry = {
'timestamp': timezone.now().isoformat(),
'Status_code': status_code,
'error_message': error_message,
}

self.transmission_status.append(new_entry)

self.transmission_status = self.transmission_status[-TRANSMISSION_STATUS_RECORDS_LIMIT:]


class GenericLearnerDataTransmissionAudit(LearnerDataTransmissionAudit):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ def transmit(self, payload, **kwargs): # pylint: disable=arguments-differ
was_successful = code < 300
learner_data.status = str(code)
learner_data.error_message = body if not was_successful else ''
learner_data.add_transmission_status(learner_data.status, learner_data.error_message)
learner_data.save()
self.enterprise_configuration.update_learner_synced_at(action_happened_at, was_successful)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Migration(migrations.Migration):

dependencies = [
('moodle', '0031_moodlelearnerdatatransmissionaudit_transmission_status'),
('moodle', '0030_merge_0028_auto_20231116_1826_0029_auto_20231106_1233'),
]

operations = [
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
"""
Tests for the base learner data transmitter.
"""
import datetime

import unittest
from unittest import mock
from unittest.mock import MagicMock, Mock

import ddt
from pytest import mark

from integrated_channels.integrated_channel.constants import TRANSMISSION_STATUS_RECORDS_LIMIT
from integrated_channels.integrated_channel.exporters.learner_data import LearnerExporter
from integrated_channels.integrated_channel.tasks import transmit_single_learner_data
from integrated_channels.integrated_channel.transmitters.learner_data import LearnerTransmitter
from integrated_channels.sap_success_factors.models import SapSuccessFactorsLearnerDataTransmissionAudit
from integrated_channels.sap_success_factors.transmitters import learner_data
from test_utils import factories


Expand All @@ -29,13 +26,6 @@ def setUp(self):
super().setUp()

enterprise_customer = factories.EnterpriseCustomerFactory(name='Starfleet Academy')
self.enterprise_customer_user = factories.EnterpriseCustomerUserFactory(
enterprise_customer=enterprise_customer,
)
self.enterprise_course_enrollment = factories.EnterpriseCourseEnrollmentFactory(
id=5,
enterprise_customer_user=self.enterprise_customer_user,
)

# We need some non-abstract configuration for these things to work,
# so it's okay for it to be any arbitrary channel. We randomly choose SAPSF.
Expand All @@ -47,25 +37,6 @@ def setUp(self):
sapsf_user_id="user_id",
secret="client_secret",
)
self.payload = SapSuccessFactorsLearnerDataTransmissionAudit(
enterprise_course_enrollment_id=self.enterprise_course_enrollment.id,
course_id='course-v1:edX+DemoX+DemoCourse',
course_completed=True,
sap_completed_timestamp=1486855998,
completed_timestamp=datetime.datetime.fromtimestamp(1486855998),
total_hours=1.0,
grade=.9,
)
self.exporter = lambda payloads=self.payload: mock.MagicMock(
export=mock.MagicMock(return_value=iter(payloads))
)
# Mocks
create_course_completion_mock = mock.patch(
'integrated_channels.sap_success_factors.client.SAPSuccessFactorsAPIClient.create_course_completion'
)

self.create_course_completion_mock = create_course_completion_mock.start()
self.addCleanup(create_course_completion_mock.stop)

self.learner_transmitter = LearnerTransmitter(self.enterprise_config)

Expand Down Expand Up @@ -222,23 +193,3 @@ def test_learner_data_transmission_dry_run_mode(self, already_transmitted_mock,
)
# with dry_run_mode_enabled = True we shouldn't be able to call this method
assert not self.learner_transmitter.client.create_assessment_reporting.called

def test_transmission_status_learner_data_transmission(self):
"""
Test that transmission status records three most recent status instances.
"""
self.create_course_completion_mock.return_value = 200, ''

transmitter = learner_data.SapSuccessFactorsLearnerTransmitter(self.enterprise_config)
for _ in range(TRANSMISSION_STATUS_RECORDS_LIMIT + 1):
if _ == TRANSMISSION_STATUS_RECORDS_LIMIT:
self.create_course_completion_mock.return_value = 400, '{"error":{"code":null,"message":"Invalid value for property \'courseCompleted\'."}}'
transmitter.transmit(self.exporter([self.payload]))
actual_transmission_status = self.payload.transmission_status

expected_transmission_status = [
{'timestamp': mock.ANY, 'Status_code': '200', 'error_message': ''},
{'timestamp': mock.ANY, 'Status_code': '200', 'error_message': ''},
{'timestamp': mock.ANY, 'Status_code': '400', 'error_message': 'Client create_course_completion failed: {"error":{"code":null,"message":"Invalid value for property \'courseCompleted\'."}}'},
]
assert expected_transmission_status == actual_transmission_status

0 comments on commit 1e69e78

Please sign in to comment.