Exemple #1
0
    def test_add_new_hotel_case(self):
        h = Hotel(
            title='테넷',
            link='https://naver.com',
            image=
            'https://ssl.pstatic.net/imgmovie/mdi/mit110/1323/132345_P01_153355.jpg',
            pubDate='2001',
            userRating='10.00')
        h.save()

        assert h.title == '테넷' and h.link == 'https://naver.com' and h.image == 'https://ssl.pstatic.net/imgmovie/mdi/mit110/1323/132345_P01_153355.jpg' and h.pubDate == '2001' and h.userRating == '10.00'
Exemple #2
0
def submit(request):
    name = request.POST['name']
    owner = request.POST['owner']
    location = request.POST['location']
    review = request.POST['review']
    youtube_video = request.POST['youtube_video']
    hotel = Hotel(name=name,
                  owner=owner,
                  location=location,
                  review=review,
                  youtube_video=youtube_video)
    hotel.save()
    messages.success(request, 'Indeed you added a Hotel')
    return HttpResponseRedirect(reverse('hotel:list'))
Exemple #3
0
 def handle(self, *args, **options):
     headers = {
         'Content-Type': 'plain/text',
         'X-Naver-Client-Id': 'L7fdgHlj4mgWbysxowRw',
         'X-Naver-Client-Secret': 'fUtZiApJSR'
     }
     url = 'https://openapi.naver.com/v1/search/movie?query=starwars&display=100&start=1&genre=&country=&yearfrom=1980&yearto=2020'
     res = requests.get(url=url, headers=headers)
     data = res.json()['items']
     for mo in data:
         hotel = Hotel(title=mo['title'],
                       link=mo['link'],
                       image=mo['image'],
                       pubDate=mo['pubDate'],
                       userRating=mo['userRating'])
         hotel.save()
Exemple #4
0
import random
from faker import Faker

from hotel.models import Hotel

fake = Faker()

for i in range(5):
    hotel = Hotel()

    hotel.name = fake.name()
    hotel.location = fake.address()
    hotel.stars = random.randint(1, 5)

    hotel.save()

#    print(i)