コード例 #1
0
ファイル: album.py プロジェクト: hammygoonan/Flaskify
    def test_date_changed_after_update(self):
        """Test that the `last_updated` field is updated on save."""
        album = Artist("Off the Wall")
        db.session.add(album)
        db.session.commit()
        created = album.last_updated

        sleep(1)
        album.name = "POff the Wall"
        db.session.commit()
        updated = album.last_updated
        self.assertNotEqual(created, updated)
コード例 #2
0
def test_date_changed_after_update(db):
    """Test that the `last_updated` field is updated on save."""
    artist = Artist(name='Michael Jackson')
    db.session.add(artist)
    db.session.commit()
    created = artist.last_updated

    sleep(1)
    artist.name = "Phil Collins"
    db.session.commit()
    updated = artist.last_updated
    assert created != updated
コード例 #3
0
ファイル: artist.py プロジェクト: hammygoonan/Flaskify
    def test_date_changed_after_update(self):
        """Test that the `last_updated` field is updated on save."""
        artist = Artist('Michael Jackson')
        db.session.add(artist)
        db.session.commit()
        created = artist.last_updated

        sleep(1)
        artist.name = "Phil Collins"
        db.session.commit()
        updated = artist.last_updated
        self.assertNotEqual(created, updated)
コード例 #4
0
def test_can_update_artist(db):
    """Test can update Artist."""
    artist = Artist(name='Michael Jackson')
    db.session.add(artist)
    db.session.commit()

    artist = Artist.query.filter_by(name='Michael Jackson').first()
    artist.name = "Phil Collins"
    db.session.add(artist)
    db.session.commit()

    artist = Artist.query.filter_by(name='Phil Collins').first()
    assert 'Phil Collins' == artist.name

    artist = Artist.query.filter_by(name='Michael Jackson').first()
    assert artist is None
コード例 #5
0
ファイル: artist.py プロジェクト: hammygoonan/Flaskify
    def test_can_update_artist(self):
        """Test can update Artist."""
        artist = Artist('Michael Jackson')
        db.session.add(artist)
        db.session.commit()

        artist = Artist.query.filter_by(name='Michael Jackson').first()
        artist.name = "Phil Collins"
        db.session.add(artist)
        db.session.commit()

        artist = Artist.query.filter_by(name='Phil Collins').first()
        self.assertEqual('Phil Collins', artist.name)

        artist = Artist.query.filter_by(name='Michael Jackson').first()
        self.assertIsNone(artist)