コード例 #1
0
ファイル: tests.py プロジェクト: sai9912/mypyton
 def setUp_createAccount(self):
     country = Country(slug='BE', name='Belgium')
     country.save()
     member_organisation = MemberOrganisation(name='GS1',
                                              slug='gs1',
                                              is_active=1,
                                              country=country)
     member_organisation.save()
     data = {
         'uuid': '53900011',
         'email': '*****@*****.**',
         'company_prefix': '53900011,53900012',
         'company_name': 'GS1 Ireland',
         'credits': '39:20,43:100,44:100',
         'txn_ref': 'Test_1,Test_3,Test_2',
         'member_organisation': 'gs1'
     }
     url = '/API/v0/AccountCreateOrUpdate/'
     response = self.client.post(url, data=data)
     assert response.status_code == 302
     self.client.get(response.url)
     user = User.objects.get(email='*****@*****.**')
     user.profile.agreed = True
     user.profile.save()
     prefix = prefix_service.find_item(user=user, prefix='53900011')
     assert prefix.prefix == '53900011'
     prefix_service.make_active(user=user, prefix=prefix.prefix)
     self.user = user
     return user
コード例 #2
0
 def setUp(self):
     country = Country(slug='BE', name='Belgium')
     country.save()
     self.member_organisation = MemberOrganisation(
         name='GS1',
         slug='gs1',
         is_active=1,
         country=country,
         gs1_prefix_regex='^539|^501|^509|^0\\d\\d')
     self.member_organisation.save()
     self.company_orgnisation = CompanyOrganisation.objects.create(
         **{
             'uuid': '53900011',
             'company': 'GS1 Ireland',
             'name': 'GS1 Ireland',
             'member_organisation': self.member_organisation,
             'country': country,
         })
     self.user = User.objects.create_user(username='******',
                                          password='******')
     mo_admin_group = Group.objects.create(name='MO Admins')
     self.user.groups.add(mo_admin_group)
     self.member_organisation.add_user(self.user)
     self.company_orgnisation.add_user(self.user)
     self.user.profile.company_organisation = self.company_orgnisation
     self.user.profile.member_organisation = self.member_organisation
     self.user.profile.save()
コード例 #3
0
 def setUpTestData(cls):
     country = Country(slug='BE', name='Belgium')
     country.save()
     cls.member_organisation = MemberOrganisation(
         name='GS1',
         slug='gs1',
         is_active=1,
         country=country,
         gs1_prefix_regex='^539|^501|^509|^0\\d\\d')
     cls.member_organisation.save()
     cls.company_orgnisation = CompanyOrganisation.objects.create(
         **{
             'uuid': '53900011',
             'company': 'GS1 Ireland',
             'name': 'GS1 Ireland',
             'member_organisation': cls.member_organisation,
             'country': country,
         })
     cls.user = User.objects.create_user(username='******',
                                         password='******')
     mo_admin_group = Group.objects.create(name='MO Admins')
     cls.user.groups.add(mo_admin_group)
     cls.member_organisation.add_user(cls.user)
     cls.company_orgnisation.add_user(cls.user)
     cls.user.profile.company_organisation = cls.company_orgnisation
     cls.user.profile.member_organisation = cls.member_organisation
     cls.user.profile.save()
     cls.token = cls.get_token_from_data({
         'username': '******',
         'password': '******'
     })
     cls.reverse_url = reverse(cls.reverse_url_name,
                               kwargs=cls.reverse_url_kwarg)
コード例 #4
0
 def setUpTestData(cls):
     country = Country(slug='IE', name='Ireland')
     country.save()
     cls.member_organisation = MemberOrganisation(name='GS1',
                                                  slug='gs1',
                                                  is_active=1,
                                                  country=country)
     cls.member_organisation.save()
     cls.company_orgnisation = CompanyOrganisation.objects.create(
         **{
             'uuid': '53900011',
             'company': 'GS1 Ireland',
             'name': 'GS1 Ireland',
             'member_organisation': cls.member_organisation,
             'country': country,
         })
     cls.user = User.objects.create_user(username='******',
                                         password='******')
     mo_admin_group = Group.objects.create(name='MO Admins')
     cls.user.groups.add(mo_admin_group)
     cls.member_organisation.add_user(cls.user)
     cls.company_orgnisation.add_user(cls.user)
     cls.profile = cls.user.profile
     cls.profile.member_organisation_id = 1
     cls.profile.save()
     cls.token = cls.get_token_from_data({
         'username': '******',
         'password': '******'
     })
コード例 #5
0
 def setUp(self):
     country = Country(slug='BE', name='Belgium')
     country.save()
     self.member_organisation = MemberOrganisation(name='GS1',
                                                   slug='gs1',
                                                   is_active=1,
                                                   country=country)
     self.member_organisation.save()
     self.company_orgnisation = CompanyOrganisation.objects.create(
         **{
             'uuid': '53900011',
             'company': 'GS1 Ireland',
             'name': 'GS1 Ireland',
             'member_organisation': self.member_organisation,
             'country': country,
         })
     self.user = User.objects.create_user(username='******',
                                          password='******')
     self.mo_user = MemberOrganisationUser.objects.create(
         user=self.user,
         organization=self.member_organisation,
         is_admin=True,
     )
     self.company_orgnisation.add_user(self.user)
     self.profile = self.user.profile
     self.profile.member_organisation_id = 1
     self.profile.save()
     response = self.client.post(reverse('api:login'),
                                 data={
                                     'username': '******',
                                     'password': '******'
                                 })
     self.token = response.data['token']
     self.client.credentials(HTTP_AUTHORIZATION='Token ' + self.token)
コード例 #6
0
 def setUpTestData(cls):
     country = Country(slug='BE', name='Belgium')
     country.save()
     cls.member_organisation = MemberOrganisation(name='GS1',
                                                  slug='gs1',
                                                  is_active=1,
                                                  country=country)
     cls.member_organisation.save()
     cls.company_organisation = CompanyOrganisation.objects.create(
         **{
             'uuid': '53900011',
             'company': 'GS1 Ireland',
             'name': 'GS1 Ireland',
             'member_organisation': cls.member_organisation,
             'country': country,
         })
     cls.user = User.objects.create_user(username='******',
                                         password='******')
     cls.company_organisation.add_user(cls.user)
     cls.token = cls.get_token_from_data({
         'username': '******',
         'password': '******'
     })
     cls.reverse_url = reverse(cls.reverse_url_name,
                               kwargs=cls.reverse_url_kwarg)
コード例 #7
0
ファイル: tests.py プロジェクト: sai9912/mypyton
 def setUp(self):
     country = Country(slug='BE', name='Belgium')
     country.save()
     member_organisation = MemberOrganisation(name='GS1IE',
                                              slug='gs1ie',
                                              is_active=1,
                                              country=country)
     member_organisation.save()
コード例 #8
0
ファイル: tests.py プロジェクト: sai9912/mypyton
 def setUp(self):
     country = Country(slug='BE', name='Belgium')
     country.save()
     member_organisation = MemberOrganisation(name='GS1SE',
                                              slug='gs1se',
                                              is_active=1,
                                              country=country,
                                              pk=7)
     member_organisation.save()
     PackageLevel.objects.create(id=70, unit_descriptor='test')
コード例 #9
0
 def setUp(self):
     country = Country(slug='BE', name='Belgium')
     country.save()
     member_organisation = MemberOrganisation(name='GS1',
                                              slug='gs1',
                                              is_active=1,
                                              country=country)
     member_organisation.save()
     response = self.client.post('/API/v1/AccountCreateOrUpdate/', self.post_data)
     response = self.client.get(response.url)
     pass
コード例 #10
0
 def setUpTestData(cls):
     super(ProductDefaultAPITestCase, cls).setUpTestData()
     cls.product = cls.create_sample_product()
     CountryOfOrigin.objects.create(code='21', name='BELGIUM')
     CountryOfOrigin.objects.create(code='103', name='IRELAND')
     TargetMarket.objects.create(code='21', market='BELGIUM')
     TargetMarket.objects.create(code='103', market='IRELAND')
     Language.objects.create(slug='en', name='English')
     country_ie = Country(slug='IE', name='Ireland')
     country_ie.save()
     cls.company_organisation.country = country_ie
     cls.company_organisation.save()
コード例 #11
0
    def setUp(self):
        country = Country(slug='BE', name='Belgium')
        country.save()
        member_organisation = MemberOrganisation(
            name='GS1 Belgium',
            slug='gs1-belgium',
            is_active=1,
            gs1_enable_advanced_dashboard=True,
            country=country)
        member_organisation.save()

        self.user1 = self.setUp_create_user1()
        self.user2 = self.setUp_create_user2()
コード例 #12
0
 def setUp(self):
     country = Country(slug='BE', name='Belgium')
     country.save()
     member_organisation = MemberOrganisation(name='GS1',
                                              slug='gs1',
                                              is_active=1,
                                              country=country)
     member_organisation.save()
     response = self.client.post('/API/v0/AccountCreateOrUpdate/',
                                 self.post_data)
     self.client.get(response.url)
     self.user = User.objects.get(email='*****@*****.**')
     assert self.user is not None
     self.user.profile.agreed = True
     self.user.profile.save()
コード例 #13
0
ファイル: tests.py プロジェクト: sai9912/mypyton
    def setUp(self):
        country = Country(slug='BE', name='Belgium', pk=7)
        country.save()
        member_organisation = MemberOrganisation(name='GS1SE',
                                                 slug='gs1se',
                                                 is_active=1,
                                                 country=country,
                                                 pk=7)
        member_organisation.save()
        sv = Language.objects.create(slug='sv', name='Swedish')
        en = Language.objects.create(slug='en', name='English')

        LanguageByCountry.objects.create(country=country,
                                         language=en,
                                         default=True)
        LanguageByCountry.objects.create(country=country,
                                         language=sv,
                                         default=False)
        PackageLevel.objects.create(id=70, unit_descriptor='test')
コード例 #14
0
 def setUpTestData(cls):
     cls.country = Country(slug='BE', name='Belgium')
     cls.country.save()
     cls.member_organisation = MemberOrganisation(
         name='GS1', slug='gs1', is_active=1, country=cls.country
     )
     cls.member_organisation.save()
     cls.company_organisation = CompanyOrganisation.objects.create(**{
         'uuid': '53900011',
         'company': 'GS1 Ireland',
         'name': 'GS1 Ireland',
         'member_organisation': cls.member_organisation,
         'country': cls.country,
     })
     cls.prefix = mixer.blend(Prefix, prefix='12345678900')
     cls.prefix.make_starting_from()
     cls.user = User.objects.create_user(username='******', password='******')
     cls.company_organisation.add_user(cls.user)
     cls.token = cls.get_token_from_data(**{'username': '******', 'password': '******'})
コード例 #15
0
ファイル: tests.py プロジェクト: sai9912/mypyton
    def test_load_templates_gs1ie_command(self):
        country = Country(slug='IE', name='Ireland')
        country.save()
        member_organisation = MemberOrganisation(name='GS1IE',
                                                 slug='gs1ie',
                                                 is_active=1,
                                                 country=country)
        member_organisation.save()
        PackageLevel.objects.create(id=60, unit_descriptor='gs1ie-inner-pack')
        PackageLevel.objects.create(id=50, unit_descriptor='gs1ie-inner-case')
        PackageLevel.objects.create(id=40,
                                    unit_descriptor='gs1ie-display_unit')
        PackageLevel.objects.create(id=30,
                                    unit_descriptor='gs1ie-inner-pallet')
        PackageType.objects.create(code='AA',
                                   type_i18n=json.dumps({'en': 'Type AA'}))
        PackageType.objects.create(code='AE',
                                   type_i18n=json.dumps({'en': 'Type AE'}))
        PackageType.objects.create(code='AM',
                                   type_i18n=json.dumps({'en': 'Type AM'}))

        self.assertEquals(ProductAttribute.objects.count(), 0)
        self.assertEquals(ProductTemplate.objects.count(), 0)
        call_command(
            'load_templates_i18n',
            xlsx_path_mask=
            'deployment/test_files/UI_presets_v2_templates_gs1ie_test.xlsx')
        # count test
        self.assertEquals(ProductTemplate.objects.count(), 5)
        self.assertEquals(
            ProductTemplate.objects.get(
                name='gs1ie-inner-pack').attributes.all().count(), 41)
        self.assertEquals(
            ProductTemplate.objects.get(
                name='gs1ie-inner-case').attributes.all().count(), 41)
        self.assertEquals(
            ProductTemplate.objects.get(
                name='gs1ie-display-unit').attributes.all().count(), 41)
        self.assertEquals(
            ProductTemplate.objects.get(
                name='gs1ie-inner-pallet').attributes.all().count(), 41)
        self.assertEquals(ProductPackaging.objects.count(), 3)