Пример #1
0
 def test_validator(self):
     eq_(AppFeatures.objects.count(), 0)
     update_features(ids=(self.app.pk,))
     assert self.mock_validator.called
     eq_(AppFeatures.objects.count(), 1)
     features = self.app.current_version.get_features().to_dict()
     eq_(AppFeatures().to_dict(), features)
Пример #2
0
 def test_validator_with_results(self):
     feature_profile = ['APPS', 'ACTIVITY']
     self.mock_validator.return_value = json.dumps(
         {'feature_profile': feature_profile})
     update_features(ids=(self.app.pk, ))
     assert self.mock_validator.called
     features = self.app.current_version.features.to_dict()
     eq_(features['has_apps'], True)
     eq_(features['has_activity'], True)
     eq_(features['has_sms'], False)
Пример #3
0
 def test_validator_with_results(self):
     feature_profile = ['APPS', 'ACTIVITY']
     self.mock_validator.return_value = json.dumps({
         'feature_profile': feature_profile
     })
     update_features(ids=(self.app.pk,))
     assert self.mock_validator.called
     features = self.app.current_version.features.to_dict()
     eq_(features['has_apps'], True)
     eq_(features['has_activity'], True)
     eq_(features['has_sms'], False)
Пример #4
0
    def test_validator_with_results_existing_empty_profile(self):
        feature_profile = ['APPS', 'ACTIVITY']
        self.mock_validator.return_value = json.dumps(
            {'feature_profile': feature_profile})
        version = self.app.current_version
        eq_(AppFeatures.objects.count(), 1)
        eq_(version.features.to_list(), [])
        update_features(ids=(self.app.pk, ))
        assert self.mock_validator.called
        eq_(AppFeatures.objects.count(), 1)

        # Features are cached on the version, therefore reload the app since we
        # were using the same instance as before.
        self.app.reload()
        features = self.app.current_version.features.to_dict()
        eq_(features['has_apps'], True)
        eq_(features['has_activity'], True)
        eq_(features['has_sms'], False)
Пример #5
0
    def test_validator_with_results_existing_empty_profile(self):
        feature_profile = ['APPS', 'ACTIVITY']
        self.mock_validator.return_value = json.dumps({
            'feature_profile': feature_profile
        })
        version = self.app.current_version
        eq_(AppFeatures.objects.count(), 1)
        eq_(version.features.to_list(), [])
        update_features(ids=(self.app.pk,))
        assert self.mock_validator.called
        eq_(AppFeatures.objects.count(), 1)

        # Features are cached on the version, therefore reload the app since we
        # were using the same instance as before.
        self.app.reload()
        features = self.app.current_version.features.to_dict()
        eq_(features['has_apps'], True)
        eq_(features['has_activity'], True)
        eq_(features['has_sms'], False)
Пример #6
0
 def test_validator(self):
     update_features(ids=(self.app.pk, ))
     assert self.mock_validator.called
     features = self.app.current_version.features.to_dict()
     eq_(AppFeatures().to_dict(), features)
Пример #7
0
 def test_ignore_non_empty_features_profile(self):
     version = self.app.current_version
     version.features.update(has_sms=True)
     update_features(ids=(self.app.pk, ))
     assert not self.mock_validator.called
Пример #8
0
 def test_ignore_no_current_version(self):
     self.app.current_version.all_files[0].update(
         status=amo.STATUS_DISABLED)
     self.app.update_version()
     update_features(ids=(self.app.pk, ))
     assert not self.mock_validator.called
Пример #9
0
 def test_validator(self):
     update_features(ids=(self.app.pk,))
     assert self.mock_validator.called
     features = self.app.current_version.features.to_dict()
     eq_(AppFeatures().to_dict(), features)
Пример #10
0
 def test_ignore_non_empty_features_profile(self):
     version = self.app.current_version
     version.features.update(has_sms=True)
     update_features(ids=(self.app.pk,))
     assert not self.mock_validator.called
Пример #11
0
 def test_ignore_no_current_version(self):
     self.app.current_version.all_files[0].update(status=amo.STATUS_DISABLED)
     self.app.update_version()
     update_features(ids=(self.app.pk,))
     assert not self.mock_validator.called
Пример #12
0
 def test_ignore_existing_features_profile(self):
     version = self.app.current_version
     AppFeatures.objects.create(version=version)
     update_features(ids=(self.app.pk,))
     assert not self.mock_validator.called