Skip to content

Commit

Permalink
fix: framing up the revert
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnagro committed Jan 18, 2024
1 parent 7afe90a commit 0ca71e4
Show file tree
Hide file tree
Showing 13 changed files with 200 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ class Migration(migrations.Migration):
('blackboard', '0017_alter_historicalblackboardenterprisecustomerconfiguration_options'),
]

operations = [
migrations.AddField(
model_name='blackboardlearnerassessmentdatatransmissionaudit',
name='transmission_status',
field=models.JSONField(blank=True, default=list, null=True),
),
migrations.AddField(
model_name='blackboardlearnerdatatransmissionaudit',
name='transmission_status',
field=models.JSONField(blank=True, default=list, null=True),
),
]
# johnnagro 20240118 DOS-4490
# Making this migration a no-op to revert a partially applied deploy migration
# operations = [
# migrations.AddField(
# model_name='blackboardlearnerassessmentdatatransmissionaudit',
# name='transmission_status',
# field=models.JSONField(blank=True, default=list, null=True),
# ),
# migrations.AddField(
# model_name='blackboardlearnerdatatransmissionaudit',
# name='transmission_status',
# field=models.JSONField(blank=True, default=list, null=True),
# ),
# ]

operations = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 3.2.22 on 2024-01-18 18:22

from django.apps import apps
from django.db import migrations
from django.core.exceptions import FieldDoesNotExist


class Migration(migrations.Migration):

dependencies = [
('blackboard', '0018_auto_20240110_1301'),
]

# johnnagro 20240118 DOS-4490
# we are reverting a partially applied deployment migration
# this migration conditionally cleans up the previous migration operations
# only if they were part of the partially applied ones

BlackboardLearnerAssessmentDataTransmissionAudit = apps.get_model('blackboard', 'BlackboardLearnerAssessmentDataTransmissionAudit')
BlackboardLearnerDataTransmissionAudit = apps.get_model('blackboard', 'BlackboardLearnerDataTransmissionAudit')

operations = []

try:
if BlackboardLearnerDataTransmissionAudit._meta.get_field('transmission_status'):
operations.append(
migrations.RemoveField(
model_name='blackboardlearnerdatatransmissionaudit',
name='transmission_status',
)
)
except FieldDoesNotExist:
pass

try:
if BlackboardLearnerAssessmentDataTransmissionAudit._meta.get_field('transmission_status'):
operations.append(
migrations.RemoveField(
model_name='blackboardlearnerassessmentdatatransmissionaudit',
name='transmission_status',
)
)
except FieldDoesNotExist:
pass
21 changes: 21 additions & 0 deletions integrated_channels/canvas/migrations/0034_auto_20240118_1822.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.22 on 2024-01-18 18:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('canvas', '0033_auto_20240110_1301'),
]

operations = [
migrations.RemoveField(
model_name='canvaslearnerassessmentdatatransmissionaudit',
name='transmission_status',
),
migrations.RemoveField(
model_name='canvaslearnerdatatransmissionaudit',
name='transmission_status',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.22 on 2024-01-18 18:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('cornerstone', '0032_cornerstonelearnerdatatransmissionaudit_transmission_status'),
]

operations = [
migrations.RemoveField(
model_name='cornerstonelearnerdatatransmissionaudit',
name='transmission_status',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.22 on 2024-01-18 18:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('degreed', '0032_degreedlearnerdatatransmissionaudit_transmission_status'),
]

operations = [
migrations.RemoveField(
model_name='degreedlearnerdatatransmissionaudit',
name='transmission_status',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.22 on 2024-01-18 18:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('degreed2', '0024_degreed2learnerdatatransmissionaudit_transmission_status'),
]

operations = [
migrations.RemoveField(
model_name='degreed2learnerdatatransmissionaudit',
name='transmission_status',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.22 on 2024-01-18 18:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('integrated_channel', '0031_genericlearnerdatatransmissionaudit_transmission_status'),
]

operations = [
migrations.RemoveField(
model_name='genericlearnerdatatransmissionaudit',
name='transmission_status',
),
]
16 changes: 0 additions & 16 deletions integrated_channels/integrated_channel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,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 +605,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
@@ -0,0 +1,17 @@
# Generated by Django 3.2.22 on 2024-01-18 18:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('moodle', '0032_auto_20240117_1202'),
]

operations = [
migrations.RemoveField(
model_name='moodlelearnerdatatransmissionaudit',
name='transmission_status',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.22 on 2024-01-18 18:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('sap_success_factors', '0015_sapsuccessfactorslearnerdatatransmissionaudit_transmission_status'),
]

operations = [
migrations.RemoveField(
model_name='sapsuccessfactorslearnerdatatransmissionaudit',
name='transmission_status',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.22 on 2024-01-18 18:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('xapi', '0012_xapilearnerdatatransmissionaudit_transmission_status'),
]

operations = [
migrations.RemoveField(
model_name='xapilearnerdatatransmissionaudit',
name='transmission_status',
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -222,23 +222,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 0ca71e4

Please sign in to comment.