All of my settings work perfectly fine and have no issue as such. Its just that CircleCI is not getting the most simplest possible test work fine. I've created a home page and wrote a test for it. The test at local ubuntu machine runs fine with python manage.py runserver and with pytest as well. Also installation and configuration works just fine in logs at CircleCI.
I would appreciate if someone can point me to right direction.
My Django Test:
from django.test import TestCase
from django.urls import reverse
class TestPage(TestCase):
def test_home_page_works(self):
response = self.client.get(reverse("home"))
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "base.html")
self.assertContains(response, "APTA")
My CircleCI config.yml:
version: 2
jobs:
build:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:3.6.2
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
- image: postgres:9.6
environment:
- POSTGRES_USER=root
- POSTGRES_DB=lims
working_directory: ~/repo
steps:
- checkout
- run:
name: Wait for db
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Install
command: |
python3 -m venv venv
. envs/test
pip install .[test]
- run:
name: Install dependencies
command: |
. venv/bin/activate
python --version
pip install -r requirements.txt
- run:
name: Collect static files
command: |
. venv/bin/activate
python apta/./manage.py collectstatic --noinput
- run:
name: Test
command: |
. venv/bin/activate
python apta/./manage.py migrate --noinput
pytest
- run:
name: Lint
command: |
. envs/test
flake8
- store_artifacts:
path: test-reports
destination: test-reports
My pytest.ini:
[pytest]
DJANGO_SETTINGS_MODULE=apta.settings
python_files = tests.py test_*.py
Error I've got at CircleCI:
apta/tests/test_views.py F [100%]
=================================== FAILURES ===================================
________________________ TestPage.test_home_page_works _________________________
self = <tests.test_views.TestPage testMethod=test_home_page_works>
def test_home_page_works(self):
> response = self.client.get(reverse("home"))
apta/tests/test_views.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
venv/lib/python3.6/site-packages/django/test/client.py:535: in get
response = super().get(path, data=data, secure=secure, **extra)
venv/lib/python3.6/site-packages/django/test/client.py:347: in get
**extra,
venv/lib/python3.6/site-packages/django/test/client.py:422: in generic
return self.request(**r)
venv/lib/python3.6/site-packages/django/test/client.py:503: in request
raise exc_value
venv/lib/python3.6/site-packages/django/core/handlers/exception.py:34: in inner
response = get_response(request)
venv/lib/python3.6/site-packages/django/core/handlers/base.py:145: in _get_response
response = self.process_exception_by_middleware(e, request)
venv/lib/python3.6/site-packages/django/core/handlers/base.py:143: in _get_response
response = response.render()
venv/lib/python3.6/site-packages/django/template/response.py:106: in render
self.content = self.rendered_content
venv/lib/python3.6/site-packages/django/template/response.py:81: in rendered_content
template = self.resolve_template(self.template_name)
venv/lib/python3.6/site-packages/django/template/response.py:63: in resolve_template
return select_template(template, using=self.using)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
template_name_list = ['base.html'], using = None
def select_template(template_name_list, using=None):
"""
Load and return a template for one of the given names.
Try names in order and return the first template found.
Raise TemplateDoesNotExist if no such template exists.
"""
if isinstance(template_name_list, str):
raise TypeError(
'select_template() takes an iterable of template names but got a '
'string: %r. Use get_template() if you want to load a single '
'template by name.' % template_name_list
)
chain = []
engines = _engine_list(using)
for template_name in template_name_list:
for engine in engines:
try:
return engine.get_template(template_name)
except TemplateDoesNotExist as e:
chain.append(e)
if template_name_list:
> raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
E django.template.exceptions.TemplateDoesNotExist: base.html
venv/lib/python3.6/site-packages/django/template/loader.py:47: TemplateDoesNotExist
------------------------------ Captured log call -------------------------------
log.py 228 ERROR Internal Server Error: /
Traceback (most recent call last):
File "/home/circleci/repo/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/circleci/repo/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 145, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/circleci/repo/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 143, in _get_response
response = response.render()
File "/home/circleci/repo/venv/lib/python3.6/site-packages/django/template/response.py", line 106, in render
self.content = self.rendered_content
File "/home/circleci/repo/venv/lib/python3.6/site-packages/django/template/response.py", line 81, in rendered_content
template = self.resolve_template(self.template_name)
File "/home/circleci/repo/venv/lib/python3.6/site-packages/django/template/response.py", line 63, in resolve_template
return select_template(template, using=self.using)
File "/home/circleci/repo/venv/lib/python3.6/site-packages/django/template/loader.py", line 47, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: base.html
=========================== 1 failed in 0.85 seconds ===========================
Exited with code 1
Related
I'm trying to create a function that returns unpacked file. It's only 1 file in archive. The problem comes with an unpacking part. I'm trying to get unpacked archive to the same folder as archive. Shell returns different not 0 values. The name seems not to be too long: Len( myFullPath ) = 101. The file name is - VZN_2022.csv.gz (packed file name)
I do not see a result of unpacking: there are no unpacked file in the folder. I use the code below:
Function Foo (ByVal myFullPath as String) as Boolean ' myFullPath = folder path + "\" + filename
Call unpackeFile( CreateObject("Scripting.FileSystemObject").GetFile(myFullPath) )
End Function
Function unpackeFile(ByRef archive As Object) As Object
....
commandStr = "C:\Program Files\7-Zip\7zFM.exe e " & archive.Path
Call Shell(commandStr, 0)
....
End function
Debug.Print commandStr
C:\Program Files\7-Zip\7zFM.exe e \\av-fs01.av.local\profiles$\meltek\Desktop\VZN_2022.csv.gz
You need to wrap the path to the executable in quotation marks too, because it has a space in it - otherwise Shell will read up to the first space (i.e., C:\Program)and assume the rest are arguments:
Function unpackeFile(ByRef archive As Object) As Object
....
commandStr = Chr(34) & "C:\Program Files\7-Zip\7zFM.exe" & Chr(34) & " e " & Chr(34) & archive.Path & Chr(34)
Call Shell(commandStr, 0)
....
End function
I need to download a really large file in msaccess via a vba application.
Using the objects MSXML2.ServerXMLHTTP.6.0 and WinHttp.WinHttpRequest.5.1 result in an error stating that there is not enough storage available to complete this operation. Therefore i resorted in using the DoFileDownload method from shdocvw.dll.
What i want to do is pass an extra header (an API key) to the request sent by the function.
Here is roughly what i want to do.
Private Declare Function DoFileDownload Lib "shdocvw.dll" _
(ByVal lpszFile As String) As Long
Public Sub Download()
sDownloadFile = StrConv(<link_to_download>, vbUnicode)
'set a header before calling DoFileDownload
Call DoFileDownload(sDownloadFile)
End Sub
How do i approach this problem?
A WebRequest downloading a whole file at once stores the whole data in response.
Although there are options to chunk response, using Wget is less coding, but more options.
Private Sub DownloadFileWget()
Const PathToWget As String = "" 'if wget is not in path use "Path\To\Wget"
Dim LinkToFile As String
Dim SavePath As String
With CreateObject("WScript.Shell")
LinkToFile = "http://download.windowsupdate.com/microsoftupdate/v6/wsusscan/wsusscn2.cab" 'huge file > 500MB
SavePath = "C:\doc" 'folder to save download
.CurrentDirectory = SavePath
.Run Chr(34) & PathToWget & "wget.exe" & Chr(34) & " --header='name: value' " & Chr(34) & LinkToFile & Chr(34) & " -N", 1, True
' -N: Continue download only if the local version is outdated.
End With
End Sub
I am trying to use browsermob-proxy to monitor all requests and responses for selenium tests. In my case, I am running the selenium tests with the py.test framework inside a docker image on jenkins. I am using the following versions:
selenium==3.8.0
pyvirtualdisplay==0.2.1
pytest==3.4.0
browsermob-proxy==0.8.0
also java openjdk-8-jdk.
Inside the py.test code I have the following line to create and start the server:
proxyserver = Server(
path="/root/tests/bsp_usecase_tests/bin/browsermob-proxy",
options={'port': 8090}
)
proxyserver.start()
driverproxy = proxyserver.create_proxy() # line 127
but in the last line I get the following error:
conftest.py:127: in basedriver
driverproxy = proxyserver.create_proxy()
/usr/local/lib/python2.7/dist-packages/browsermobproxy/server.py:40: in create_proxy
client = Client(self.url[7:], params)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <browsermobproxy.client.Client object at 0x7f1a5f73f1d0>
url = 'localhost:8090', params = {}, options = {}
def __init__(self, url, params=None, options=None):
"""
Initialises a new Client object
:param url: This is where the BrowserMob Proxy lives
:param params: URL query (for example httpProxy and httpsProxy vars)
:param options: Dictionary that can contain the port of an existing
proxy to use (for example 'existing_proxy_port_to_use')
"""
params = params if params is not None else {}
options = options if options is not None else {}
self.host = "http://" + url
if params:
urlparams = "?" + unquote(urlencode(params))
else:
urlparams = ""
if 'existing_proxy_port_to_use' in options:
self.port = options['existing_proxy_port_to_use']
else:
resp = requests.post('%s/proxy' % self.host + urlparams)
content = resp.content.decode('utf-8')
try:
jcontent = json.loads(content)
except Exception as e:
raise Exception("Could not read Browsermob-Proxy json\n"
> "Another server running on this port?\n%s..." % content[:512])
E Exception: Could not read Browsermob-Proxy json
E Another server running on this port?
E <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
E <html><head>
E <meta type="copyright" content="Copyright (C) 1996-2016 The Squid Software Foundation and contributors">
E <meta http-equiv="Content-Type" CONTENT="text/html; charset=utf-8">
E <title>ERROR: The requested URL could not be retrieved</title>
E <style type="text/css"><!--
E /*
E * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
E *
E * Squid software is distributed under GPLv2+ license and incl...
/usr/local/lib/python2.7/dist-packages/browsermobproxy/client.py:37: Exception
Maybe I forgot to copy important files into the docker image?
I have the following setup for the browsermob-proxy (besides the pip install):
bsp_usecase_tests/bin:
browsermob-proxy
bsp_usecase_tests/lib:
browsermob-dist-2.1.4.jar
i.e. I have copied the file browsermob-proxy into bin and the file browsermob-dist-2.1.4.jar into the lib folder. Also, the server itself seem to be starting and running. But I get this weird error when I try to get the proxy information I can use for the selenium driver...
Any ideas what I have done wrong, or what is missing?
Seems to me that the port is already in use. You can check if the port is being used using lsof and then kill it, if it is in use. You can check using lsof -i:8090
EDIT :
And you have already done that in this thread -
How to fix 'Address already in use' error with browsermob-proxy?
I would initialize server with
proxyserver = Server(
path="/root/tests/bsp_usecase_tests/bin/browsermob-proxy",
options={'existing_proxy_port_to_use': 8090})
This should do it.
The internal code in Browsermob-Proxy is looking for key in 'options' dictionary named 'existing_proxy_port_to_use', else it uses default i.e. empty dictionary.
I would like to convert images downloaded from the internet[1] to JPGs with ImageMagick in VBA. So far, I've attempted two methods that have both failed.
First, I tried using the ImageMagickObject 1.0 Type Library:
Private Sub CommandButtonOkay_Click()
Dim sURL As String, sNetFile As String, sLocalFile As String, _
cmd As String, RetVal As Integer, img As Object
Set img = New ImageMagickObject.MagickImage
sURL = UserForm1.TextBoxImgURL
sLocalFile = "C:\temp\" & UserForm1.TextBoxName
DownloadFile sURL, sLocalFile ' Function to download image from a URL and save it to a local directory
RetVal = img.Convert(sLocalFile, sLocalFile & ".jpg") '<-- This line produces the error
UserForm1.Hide
End Sub
This ends up giving me the following error:
The source file ("C:\temp\image") exists, but the file that was to be created ("C\temp\image.jpg") does not. This is very similar to the question posted here, but I have not been able to find a solution to that so far.
Second, I tried just calling ImageMagick using the Shell command:
Private Sub CommandButtonOkay_Click()
Dim sURL As String, sNetFile As String, sLocalFile As String, _
cmd As String, RetVal As Integer
sURL = UserForm1.TextBoxImgURL
sLocalFile = "C:\temp\" & UserForm1.TextBoxName
DownloadFile sURL, sLocalFile ' Function to download image from a URL and save it to a local directory
RetVal = Shell("convert.exe """ & sLocalFile & """ """ & sLocalFile & ".jpg""")
UserForm1.Hide
End Sub
When I run this, the image gets downloaded just fine, but the image isn't converted and no error is thrown. Furthermore, when I execute the command that the Shell command executes in a separate command window, the conversion happens exactly as I would expect.
So the question then seems to be why is the ImageMagick command working beautifully when it is operating in its own command prompt, but not working at all when operating from within VBA?
[1] I don't know if this is useful information or not, but I'm downloading the images from the internet programmatically, so I have no means of knowing what format I'm getting; however, the image I've been using to test this with is a PNG.
The problem is the Shell is really only for opening programs. Therefore, it is necessary to actually tell it to open a command prompt and run the appropriate command. This can be done by changing the line with the Shell command to the following:
RetVal = Shell("cmd.exe /c convert.exe """ & sLocalFile & """ """ & sLocalFile & ".jpg""")
I open an .exe file but the script immediately closes after opening it. How can I prevent the script from closing?
Local $engine= "C:\Users\Davis\Desktop\chessEngine\stockfish-5-win\Windows\stockfish_14053109_32bit.exe"
Run($engine, "", #SW_MAXIMIZE, $STDOUT_CHILD)
Removing $STOUT_CHILD from Run() leaves the script open after executing, but I need this to read output from the program. Why is this happening?
Local $engine = "C:\Users\Davis\Desktop\chessEngine\stockfish-5-win\Windows\stockfish_14053109_32bit.exe"
Local $iPID = Run($engine, "", #SW_MAXIMIZE, $STDOUT_CHILD)
ProcessWaitClose($iPID)
This ist an example how to get output from a DOS command.
ConsoleWrite(_getDOSOutput('ipconfig /all') & #CRLF)
Func _getDOSOutput($command)
Local $text = '', $Pid = Run('"' & #ComSpec & '" /c ' & $command, '', #SW_HIDE, 2 + 4)
While 1
$text &= StdoutRead($Pid, False, False)
If #error Then ExitLoop
Sleep(10)
WEnd
Return StringStripWS($text, 7)
EndFunc ;==>_getDOSOutput