Пример #1
0
 def new_vendor(self, name, address, tel, is_active, contact_person,
                location_id):
     vendor = Vendor(name=name,
                     address=address,
                     tel=tel,
                     is_active=is_active,
                     contact_person=contact_person,
                     location_id=location_id)
     vendor.save()
     return vendor
Пример #2
0
def _add_ps_user():
    """Helper function for creating a primary segregator user in the database"""

    vendor_params = {
        'vendor_subtype':
        'primary_segregator',
        'name':
        click.prompt('Name'),
        'podio_master_id':
        click.prompt(
            'Podio Master ID (Find using Stakeholders > Your Vendor > Developer Info > Item ID)'
        )
    }
    new_vendor = Vendor.create(**vendor_params)

    user_params = {
        'vendor_id':
        new_vendor.id,
        'email':
        click.prompt('Email'),
        'active':
        True,
        'password':
        click.prompt('Password', hide_input=True, confirmation_prompt=True)
    }
    user_params = {
        param: value
        for param, value in user_params.items() if value != ''
    }
    return User.create(**user_params)
 def setUp(self):
     self.BaseSetUp()
     self.mock_vendor = Vendor(id=1,
                               created_at=datetime.now(),
                               updated_at=datetime.now(),
                               name='Mock vendor',
                               address='Mock address',
                               tel='',
                               contact_person='Mock person',
                               is_active=True,
                               location_id=1)
     self.mock_vendor_engagement = VendorEngagement(
         id=1,
         created_at=datetime.now(),
         updated_at=datetime.now(),
         vendor_id=1,
         location_id=1,
         start_date=datetime.now(),
         end_date=datetime.now(),
         status=1,
         termination_reason='Mock reason',
         vendor=self.mock_vendor)
     self.mock_menu = Menu(is_deleted=False,
                           date=datetime.now(),
                           meal_period='',
                           location_id=1,
                           main_meal_id=1,
                           allowed_side=1,
                           allowed_protein=1,
                           side_items='',
                           protein_items='',
                           vendor_engagement_id=1,
                           created_at=datetime.now(),
                           updated_at=datetime.now())
     self.mock_vendor_engagement = VendorEngagement(
         id=1,
         created_at=datetime.now(),
         updated_at=datetime.now(),
         vendor_id=1,
         location_id=1,
         start_date=datetime.now(),
         end_date=datetime.now(),
         status=1,
         termination_reason='Mock reason',
         vendor=self.mock_vendor,
         menus=[
             self.mock_menu,
         ])
     self.mock_vendor_engagement_no_child = VendorEngagement(
         id=1,
         created_at=datetime.now(),
         updated_at=datetime.now(),
         vendor_id=1,
         location_id=1,
         start_date=datetime.now(),
         end_date=datetime.now(),
         status=1,
         termination_reason='Mock reason',
         vendor=self.mock_vendor)
Пример #4
0
def _add_vendor():
    """Helper function for creating a vendor in the database"""

    params = {
        'vendor_subtype':
        click.prompt('Vendor Subtype',
                     type=click.Choice(vendor_subtype_enum.enums)),
        'name':
        click.prompt('Name')
    }
    return Vendor.create(**params)
Пример #5
0
    def test_create_vendor_rating_ok_response(
            self, mock_vendor_repo_get, mock_auth_user,
            mock_vendor_rating_controller_request_params,
            mock_vendor_engagement_repo_get,
            mock_vendor_rating_repo_new_rating,
            mock_vendor_rating_repo_update_vendor_average_rating):
        '''Test create_vendor_rating OK response.
        '''
        # Arrange
        with self.app.app_context():
            mock_vendor = Vendor(id=1,
                                 created_at=datetime.now(),
                                 updated_at=datetime.now(),
                                 name='Mock vendor',
                                 address='Mock address',
                                 tel='',
                                 contact_person='Mock contact person',
                                 is_active=True,
                                 location_id=1)
            mock_vendor_rating = VendorRating(vendor_id=1,
                                              user_id=1,
                                              comment='Mock comment',
                                              service_date=datetime.now(),
                                              rating=1.0,
                                              channel='Mock channel',
                                              rating_type='engagement',
                                              type_id=0,
                                              engagement_id=1,
                                              id=1,
                                              created_at=datetime.now(),
                                              updated_at=datetime.now(),
                                              main_meal_id=1)
            mock_vendor_repo_get.return_value = mock_vendor
            mock_auth_user.return_value = 1
            mock_vendor_rating_controller_request_params.return_value = (
                'Mock comment', 2.0, '2019-02-01', 'Mock channel', 1)
            mock_vendor_engagement_repo_get.return_value.vendor_id = 1
            mock_vendor_rating_repo_new_rating \
                .return_value = mock_vendor_rating
            vendor_rating_controller = VendorRatingController(
                self.request_context)
            mock_vendor_rating_repo_update_vendor_average_rating.return_value = None

            # Act
            result = vendor_rating_controller.create_vendor_rating()

            # Assert
            assert result.status_code == 201
            assert result.get_json()['msg'] == 'Rating created'
 def setUp(self):
     self.BaseSetUp()
     self.fake = Faker()
     vendor = VendorFactory()
     location = LocationFactory()
     self.mock_vendor_engagement = VendorEngagement(
         id=1,
         created_at=datetime.now(),
         updated_at=datetime.now(),
         vendor_id=vendor.id,
         location_id=location.id,
         start_date=datetime.now(),
         end_date=datetime.now(),
         status=1,
         termination_reason=self.fake.text())
     self.mock_rating = VendorRating(id=1,
                                     created_at=datetime.now(),
                                     updated_at=datetime.now(),
                                     vendor_id=vendor.id,
                                     user_id=1,
                                     comment=self.fake.text(),
                                     service_date=datetime.now(),
                                     rating=1.2,
                                     channel='web',
                                     type_id=1,
                                     engagement_id=1,
                                     main_meal_id=1)
     self.mock_vendor_with_dependants = Vendor(
         id=1,
         created_at=datetime.now(),
         updated_at=datetime.now(),
         is_deleted=False,
         name=self.fake.name(),
         address=self.fake.address(),
         tel=self.fake.phone_number(),
         contact_person=self.fake.name(),
         is_active=True,
         location_id=location.id,
         ratings=[
             self.mock_rating,
         ],
         engagements=[
             self.mock_vendor_engagement,
         ])
     self.mock_vendor = Vendor(id=1,
                               created_at=datetime.now(),
                               updated_at=datetime.now(),
                               is_deleted=False,
                               name=self.fake.name(),
                               address=self.fake.address(),
                               tel=self.fake.phone_number(),
                               contact_person=self.fake.name(),
                               is_active=True,
                               location_id=location.id)
     self.mock_deleted_vendor = Vendor(id=1,
                                       created_at=datetime.now(),
                                       updated_at=datetime.now(),
                                       is_deleted=True,
                                       name=self.fake.name(),
                                       address=self.fake.address(),
                                       tel=self.fake.phone_number(),
                                       contact_person=self.fake.name(),
                                       is_active=True,
                                       location_id=location.id)