Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
41 views

How to mock properly recv method in python and use settimeout

I'm trying to use and test sockets in python (I have to use 3.5 version). Consider this code: import socket def send_recv(xml_message): try: address = ('127.0.0.1', 12000) ...
smark's user avatar
  • 17
0 votes
0 answers
25 views

Mocking a class with arguments, but getting NameError: name 'my_position' is not defined

I am trying to mock out a class that is being called/initialised in a function. def example_function(): example_class = SomeClass(my_position, num_list, suit_list) @mock.patch('.../SomeClass') ...
killerbee88's user avatar
0 votes
0 answers
17 views

Mock Router ParserError: Expected ';' but got identifier

This mock router is not working. The code is below followed by the error message in bold. I have been calling ^0.8.19 and have updated npm, and checked my hardhat config file and do not see the issue. ...
MasterBlends's user avatar
0 votes
2 answers
45 views

Why is python mock assert_any_call not matching

Given the doc for assert_any_call I have a log statement I want to assert against ... logger.warning('Backup quantity is 0, supplied uuids %s, matched machines: %s', uuids, machines) ... see the ...
James Lin's user avatar
  • 26.4k
0 votes
1 answer
39 views

Asserting that a function that is mocked is called_once but running into ValueError: not enough values to unpack (expected 2, got 0)

I am trying to unit test that a function is called within another function. def run_this_function(something): 'FOLD', {} def go_to_the_right_street(action): if street_we_are_on == '...
killerbee88's user avatar
1 vote
0 answers
28 views

How do I verify no other calls on a moq that has sub-mocks?

In the following example, I'm getting some behavior I wouldn't expect: [Test] public void Test() { var mockGetter = new Mock<IHostedServiceGetter>(); var mockService = new Mock<...
ewok's user avatar
  • 21.3k
0 votes
0 answers
45 views

Does Cypress Support Intercepting WebSocket Req and Mock response? [closed]

I might need to mock WebSocket API Response for one of the operation from Cypress for one feature testing and I saw this thread for WebSocket on Cypress https://github.com/cypress-io/cypress/issues/...
FEE's user avatar
  • 309
1 vote
0 answers
55 views

How to mock an Enum in pytest globally

I have a trading bot project, let's call it trading_bot. I am using python-binance. I have an enum class CoinName(str, Enum): USDT = "USDT" BTC = "BTC" ETH = "ETH&...
nontrivial's user avatar
0 votes
0 answers
14 views

Unittest asyncio patch object mock with nested coros

I want to mock the client of an async database client in unittest. The functioncall of the client is like: test.client.json().set(argumentsforquery) The test looks like this: @pytest.mark.asyncio ...
nico's user avatar
  • 67
0 votes
1 answer
13 views

Unit fails - Missing mocked calls

Issue: Missing mocked calls inside every { ... } block: make sure the object inside the block is a mock io.mockk.MockKException: Missing mocked calls inside every { ... } block: make sure the object ...
Equlo's user avatar
  • 197
0 votes
0 answers
20 views

Exception at mappermock.verify

Below is my service method public async Task<ServiceResponse<AnnotationMasterResponse>> CreateAnnotation(AnnotationMasterRequest annotationMasterRequest) { return await ...
Yash Depani's user avatar
0 votes
0 answers
22 views

SecretsManager mock in jest testing

i am trying to create unit test for my lambda function but keeping getting the error that Secrets Manager can't find the specified secret when calling the getSecretValue method import { SecretsManager ...
Pham Minh Khai Hoang's user avatar
0 votes
1 answer
36 views

Mock spark.read().format().options().load() but not spark.table()

I have the following function which I need to test - private HashMap<String, Dataset<Row>> getDataSources(SparkSession spark) { HashMap<String, Dataset<Row>> ds = new ...
ujjawal's user avatar
0 votes
1 answer
60 views

How to mock mongodb driver in golang

In my Golang project I need to mock mongodb to be able to write unit tests for my Repository functions. I mostly need to mock collection.Indexes.CreateMany or FindOneAndUpdateor Find or cursor.All or ...
ns.altun's user avatar
  • 170
1 vote
1 answer
27 views

Mockk how to verify that a method accepting constructor lambda is invoked

Hey there I am having issues with method accepting constructor type of lambda with following signature: class EventLog() { inline fun log(block: Builder.() -> Unit) = Builder(logger....
Alexander Petrov's user avatar
0 votes
0 answers
8 views

WireMock.Net 1.6.8 ovverides Ihttpfactory.CreateClient()?

Note that I am a novice when it comes to programming. I have an issue where I want to create an integration test for my service. The service does several external API-calls. Which is why I wanted to ...
CmF's user avatar
  • 11
0 votes
0 answers
20 views

How to check the result of a mocked function without relying on calling convention [duplicate]

In Python, can check the parameters of a mocked function using parameter names in a test without relying on the way the function was called (either with args or with kwargs)? Concrete example I'd like ...
DarkTrick's user avatar
  • 3,351
0 votes
0 answers
66 views

Dynamic Mock Data with MSW and Playwright: Synchronizing Across Threads

I am using Playwright for end-to-end testing and Mock Service Worker (MSW) for mocking API responses. My setup involves: • Playwright to test a web application. • MSW to intercept network ...
Nati Kamusher's user avatar
0 votes
1 answer
35 views

Problems testing with pytest with mock in a subclass

I'm having problems trying to mock a class called into another class. I have three modules: tree.py from branch import Branch class Tree: type_of_tree = None branches = None def ...
Rubén Pozo's user avatar
  • 1,083
0 votes
3 answers
60 views

In RSpec, how to mock a method so that it returns its argument

Let's say I have a class with a method that modifies and returns a hash. When testing the class the method will be called, but for the purposes of the test, I want it to return its argument ...
dB''s user avatar
  • 8,280
0 votes
0 answers
31 views

Why is my vi.spyOn on a mocked function not recording calls in Vitest?

I'm testing a function called compareExcelFiles in Vitest, and I'm trying to spy on the readFile function it calls internally. Despite setting up the spy with vi.spyOn, the calls to readFile aren't ...
Édor Inc's user avatar
0 votes
1 answer
26 views

Mocking an error throwing function in jest

I am trying to create a mock for a function that throws a particular error: throwCycleDetected(ticket: string): never { throw new HttpException () } However when I try to mock the function with jest:...
Petr 's user avatar
  • 11
1 vote
0 answers
52 views

Mocking boto3 client response

I am trying to build unit tests for my calls to dynamodb. I need to specify exactly what the client instance will respond with - to replicate a failure response from AWS. I can force failure responses ...
Kottok Motors's user avatar
0 votes
0 answers
21 views

How to mock a node module import in node js

I am using mocha as my testing environment in my node project and Sinon to stub and mock dependencies. I have a File Factory.js as import fs from 'fs' class Factory{ create = async(options) => {...
Saurav Khewal's user avatar
0 votes
1 answer
34 views

Patching server-side function in python-socket.io and testing client-side call

I'm trying to test a socket.io call. I have a socket.io server mounted as app into FastAPI, which is up and running and communication is working. Whenever I call foo(), that calls bar() directly in ...
aknott's user avatar
  • 220
0 votes
1 answer
26 views

How do I mock a custom hook with axios for testing?

I have a custom hook which fetches data from a third party api. I need to create a test using vitest but I can't seem to find anything that works. If any one is able to help that would be much ...
iamxanderg's user avatar
0 votes
0 answers
26 views

How to mock async functions with unittest

I want to test a function like this, with pytest: def asdf(): a = first_function() b = second_function() where a has a block like this: result_queue_first = queue.Queue() result_queue_second =...
Carabes's user avatar
  • 649
0 votes
0 answers
12 views

Using SOAP UI MockService with OnRequest script

I have created a MockService with two MockActions, each MockAction with two distinct MockResponses. Based on the incoming Request content on the MockService (not on the MockAction), I want to dispatch ...
Ricardo Lourenço's user avatar
0 votes
0 answers
20 views

Mock a ManyToMany method add

I need help. I want to test an exception case in my test, so I have to mock 'add()' method. How can I test it? my model: class CourseGroup(models.Model): students = models.ManyToManyField( ...
Iren E's user avatar
  • 361
1 vote
1 answer
42 views

Mock clickhouse-go.driver.Row.Scan(dest ...any) function to fill the first argument with mockery

I'm using mockery and i need to mock clickhouse-go.driver.Row.Scan(dest ...any) function to fill the first argument with the given data. In my case the code looks like so: func Test_1(test *testing.T) ...
George's user avatar
  • 630
0 votes
1 answer
113 views

How to Mock EntityEntry in EF Core?

I am trying to write a unit test for a method that handles exceptions and reloads an entity in Entity Framework Core. The method contains the following code: catch (DbUpdateConcurrencyException) ...
IvanH's user avatar
  • 5,139
1 vote
1 answer
50 views

Mock subscriber of a threaded publisher in Rust

I am implementing an implementation of the Command Pattern where a subscriber would receive data from a reader thread and I have issues testing my implementation using Rust mocks. Consider this ...
Mihai's user avatar
  • 1,084
0 votes
1 answer
43 views

Mock a repository request

I try to Mock a request to my database following these 2 guides and one SO question: Mocking dependencies Testing database Mock 2 repositories So I have this code: public static function ...
Skunka's user avatar
  • 615
-4 votes
1 answer
52 views

How to assert that a mock was called with an specific argument in Go?

Let's say I have a test like this func TestSomeFn(t *testing.T){ t.Run("the fn is called with x when someFunc is called with y", func(t *testing.T){ mockFn := new(MockFn) // this ...
Claudio Lillo's user avatar
0 votes
1 answer
54 views

How to write an integration Spring Boot Test for a Camunda process?

How do I write an integration test in Spring Boot to test a Camunda process? The tasks in the Camunda process that need testing also have services that call methods to make REST calls, these would ...
thecheesegrater's user avatar
1 vote
0 answers
86 views

How to mock an internal import in Deno?

Say I have module utils that imports module logger. I am about to write unit tests for module utils and I want to mock logger when logger is being tested. // utils.ts import logger from "logger&...
Lucio Paiva's user avatar
  • 20.7k
0 votes
1 answer
86 views

Is there a way to synchonize access to a singleton in C#?

I'm running into a situation while trying to run unit tests against a singleton. I'm using a singleton to manage a single HttpClient that my application can use to make Http Requests. I know that ...
Tim's user avatar
  • 123
0 votes
0 answers
21 views

Mock patching a callable upload_to in a Django ImageField

In Django I have a model and a test similar to the following, both in a photos module (Django app). models.py def get_user_photo_path(instance, filename): return str(uuid.uuid4()) class UserPhoto(...
Goluxas's user avatar
  • 177
5 votes
2 answers
126 views

Give side effect to only first call of Pytest patched function

I have a function that renders HTML templates. In case exception is thrown during rendering of a given template, a default template will be rendered (simplified version of the function below): def ...
matetam's user avatar
  • 135
0 votes
0 answers
44 views

NPM workspace share Jest manual mock

Overview I have an NPM package that uses NPM workspaces and contains four workspaces or packages. Each of these depends on some external dependencies, as well as there is some inter-package dependency ...
ashipma's user avatar
  • 475
0 votes
1 answer
38 views

Cannot mock method beavior on invocation inside configuration class

In my Spring Boot project I have a configuration class like this: @Configuration @RequiredArgsConstructor // ... using Lombok public class MyConfigClass { private final MyService myService; ...
davioooh's user avatar
  • 24.6k
0 votes
1 answer
34 views

mock throw exception and new object seems not to be working using powermock

I have following simple test case that use powermock to mock throw exception from the method of ExceptionClass.getRandom by mocking the creation of Random object. But, from the test result, it looks ...
Tom's user avatar
  • 6,302
0 votes
1 answer
27 views

Create mock for a symbol in typescript

Say I have a component: export class Component { constructor(@injectable(IDependency) dep: IDependency) {} // other methods/properties do not matter } and the dependency it requires is defined ...
Eugene Strizhok's user avatar
0 votes
0 answers
22 views

Not able to mock a class used within ProcessElement of an Apache Beam pipline [duplicate]

I can mock a static method in a class from my test case, but when I test pipelines, the same is not mocked. The same class is referenced while static mocking directly from my test case and also while ...
CyberDreadWing's user avatar
0 votes
2 answers
144 views

Is my integration test well structured and why is it returning import error

I am learning mock and trying it on a personal project. This is my project structure: project/ │ ├── src/ │ └── My_app/ │ ├── __init__.py │ ├── application/ │ │ └── main_code.py │...
Haha's user avatar
  • 1,007
0 votes
1 answer
68 views

Mocking Java CompletableFuture.supplyAsync [duplicate]

I have the following sample code. Calling different static methods from utility classes in different Completable Futures and joining them to get results together. However, while writing JUnits, call ...
user9828728's user avatar
0 votes
1 answer
36 views

I don't know the value returned to me when testing bloc in Flutter

Im developing an app on Flutter. I want to test bloc using mockito but I don't know response. (status code:200 but response is a very big and dynamic model) I read the same example in every source, I ...
twice_flutter's user avatar
0 votes
1 answer
44 views

@Spy with @InjectMocks in Mockito

I am trying to write unit test for my ProjectsService class. the calss depends on ProjectsRepository. So I annoatetd the repository with @Mock to avoid calling real database and annotate the ...
saif barakat's user avatar
0 votes
0 answers
23 views

Mocking a library that has 2 different paths/packages in jest

I was figuring out how to mock a library that has 2 different paths for example @floating-ui/react-dom and @floating-ui/dom that belongs to the same library When I mock @floating-ui/dom it seems to be ...
Yuu's user avatar
  • 445
0 votes
2 answers
46 views

LINQ Expressions in xUnit test

How can I simulate this part of my code in xUnit var updateCost = await _costOfConsomption.DeferredWhere(x => x.Id == model.CostOfConsomptionId).FirstOrDefaultAsync() ?? ...
Rezabk's user avatar
  • 1

1
2 3 4 5
320