Example #1
0
    def test_update_client_priority(self, app, db, session):
        clientJohn = Client.create(name='client John')
        john = User.create(username='******', email='*****@*****.**')
        feature = FeatureRequest.create(
            title="some feature",
            description="some description of course",
            client_id=clientJohn.id,
            client_priority=1,
            user_id=john.id,
            target_date=datetime(2018, 2, 10),
            product_area=ProductArea.POLICIES)

        assert feature.id == 1
        assert feature.client_priority == 1
        another_feature = FeatureRequest.create(
            title="some feature",
            description="some description of course",
            client_id=clientJohn.id,
            client_priority=1,
            user_id=john.id,
            target_date=datetime(2018, 2, 10),
            product_area=ProductArea.POLICIES)

        FeatureRequest.update_client_priority(another_feature)
        assert another_feature.id == 2
        assert another_feature.client_priority == 1
        assert feature.client_priority == 2
Example #2
0
    def test_post(self, app, db, session):
        client = app.test_client()
        client_john = Client.create(name='client John')
        john = User.create(username='******', email='*****@*****.**')
        response = client.post('/feature_requests/',
                               data=json.dumps({
                                   'title':
                                   'a feature request',
                                   'description':
                                   'a description',
                                   'client_id':
                                   client_john.id,
                                   'client_priority':
                                   1,
                                   'user_id':
                                   john.id,
                                   'target_date':
                                   str(datetime.utcnow()),
                                   'product_area':
                                   'Policies'
                               }),
                               headers={'Content-Type': 'application/json'})

        data = json.loads(response.get_data())
        instance = FeatureRequest.query.get(data['id'])

        assert response.status_code == 200
        assert instance.title == data['title']
        assert instance.client_priority == data['client_priority']
        assert instance.product_area.value == data['product_area']
Example #3
0
def feature_request(app, db, session):
    clientJohn = Client.create(name='client John')
    john = User.create(username='******', email='*****@*****.**')
    return FeatureRequest.create(title="some feature",
                                 description="some description of course",
                                 client_id=clientJohn.id,
                                 client_priority=1,
                                 user_id=john.id,
                                 target_date=datetime(2018, 2, 10),
                                 product_area=ProductArea.POLICIES)
Example #4
0
    def test_serialize(self, app, db, session):
        client_john = Client.create(name='client John')
        john = User.create(username='******', email='*****@*****.**')
        feature = FeatureRequest.create(
            title="some feature",
            description="some description of course",
            client_id=client_john.id,
            client_priority=1,
            user_id=john.id,
            target_date=datetime(2018, 2, 10),
            product_area=ProductArea.POLICIES)

        feature_request_schema = FeatureRequestSchema()
        result = feature_request_schema.dump(feature).data

        assert result['id'] == feature.id
        assert result['client']['id'] == client_john.id
Example #5
0
def add_user(request):
    try:
        name = request.json.get('name')
        email = request.json.get('email')
        password = request.json.get('password')
        new_user = ''
        if email:
            new_user = User(name=name,
                            email=email,
                            password=password,
                            created_on=dt.now(),
                            website="www:http://w3schools.com")
            db.session.add(new_user)  # Adds new User record to database
            db.session.commit()  # Commits all changes
        send_mail()
        return f"{new_user} successfully created!"
    except Exception as e:
        print(e)
        return "Error in creating User"
Example #6
0
 def test_create(self, db, app, session):
     john = User.create(username='******', email='*****@*****.**')
     print(john)
     assert john.id == 1